//
//  LJP_GuideHeadView.m
//  God_is_a_Girl
//
//  Created by 李继鹏 on 15/10/4.
//  Copyright (c) 2015年 呸. All rights reserved.
//

#import "LJP_GuideHeadView.h"
#import <UIImageView+WebCache.h>
#import "LJP_GuideHeadModel.h"
@implementation LJP_GuideHeadView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        UIVisualEffectView *effect = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
        effect.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
        effect.alpha = 1;
        [self addSubview:self.backView];
        [self addSubview:effect];
        self.picture = [[UIImageView alloc] initWithFrame:CGRectMake(20, 30, 100, 100)];
        self.headPicture = [[UIImageView alloc] initWithFrame:CGRectMake(140, 40, 30, 30)];
        self.headPicture.layer.cornerRadius = 15;
        self.headPicture.layer.masksToBounds = YES;
        self.name = [[UILabel alloc] initWithFrame:CGRectMake(180, 40, [UIScreen mainScreen].bounds.size.width - 190, 30)];
        self.writer = [[UILabel alloc] initWithFrame:CGRectMake(130, 70, [UIScreen mainScreen].bounds.size.width - 150, 20)];
        self.info = [[UILabel alloc] initWithFrame:CGRectMake(130, 70, [UIScreen mainScreen].bounds.size.width - 150, 60)];
        self.info.numberOfLines = 2;
        self.info.font = [UIFont systemFontOfSize:14];
        self.info.textColor = [UIColor whiteColor];
        self.name.font = [UIFont systemFontOfSize:18];
        self.name.textColor = [UIColor whiteColor];
        [self addSubview:self.picture];
        [self addSubview:self.headPicture];
        [self addSubview:self.name];
        [self addSubview:self.info];
        
    }
    return self;
}
- (void)setModel:(LJP_GuideHeadModel *)model
{
    if (model != _model) {
        _model = model;
    }
    [self.backView sd_setImageWithURL:[NSURL URLWithString:_model.coverSmall] placeholderImage:[UIImage imageNamed:@"search"]];
    [self.picture sd_setImageWithURL:[NSURL URLWithString:_model.coverSmall] placeholderImage:[UIImage imageNamed:@"search"]];
    [self.headPicture sd_setImageWithURL:[NSURL URLWithString:_model.avatarPath] placeholderImage:[UIImage imageNamed:@"search"]];
    self.name.text = _model.nickname;
    self.info.text = _model.tags;
}

@end
